package Dame;

public class BinarySearchDame {
    public static void main(String[] args) {
        int arr [] = {1,2,3,4,5,6,7,8,9,10};
        int a = 10;

        int b = binarySearchDame(arr,a);
        System.out.println(b);
    }

    private static int binarySearchDame(int[] arr, int a) {
        int min =0;
        int max = arr.length-1;
        while (min <= max) {
                int mid = (min +max)>>1;
                if (arr[mid]<a){
                    min = mid+1;
                }else if (arr[mid]>a){
                    max = mid -1;
                }else {
                    return mid;
                }
            }
            return -1;
        }
    }

